{"ast":null,"code":";\nexport class ParallelHasher {\n  constructor(workerUri, workerOptions) {\n    this._queue = [];\n    this._ready = true;\n    const self = this;\n    if (Worker) {\n      self._hashWorker = new Worker(workerUri, workerOptions);\n      self._hashWorker.onmessage = self._recievedMessage.bind(self);\n      self._hashWorker.onerror = err => {\n        self._ready = false;\n        console.error('Hash worker failure', err);\n      };\n    } else {\n      self._ready = false;\n      console.error('Web Workers are not supported in this browser');\n    }\n  }\n  /**\n   * Hash a blob of data in the worker\n   * @param blob Data to hash\n   * @returns Promise of the Hashed result\n   */\n  hash(blob) {\n    const self = this;\n    let promise;\n    promise = new Promise((resolve, reject) => {\n      self._queue.push({\n        blob,\n        resolve,\n        reject\n      });\n      self._processNext();\n    });\n    return promise;\n  }\n  /** Terminate any existing hash requests */\n  terminate() {\n    this._ready = false;\n    this._hashWorker.terminate();\n  }\n  // Processes the next item in the queue\n  _processNext() {\n    if (this._ready && !this._processing && this._queue.length > 0) {\n      this._processing = this._queue.pop();\n      this._hashWorker.postMessage(this._processing.blob);\n    }\n  }\n  // Hash result is returned from the worker\n  _recievedMessage(evt) {\n    var _a, _b;\n    const data = evt.data;\n    if (data.success) {\n      (_a = this._processing) === null || _a === void 0 ? void 0 : _a.resolve(data.result);\n    } else {\n      (_b = this._processing) === null || _b === void 0 ? void 0 : _b.reject(data.result);\n    }\n    this._processing = undefined;\n    this._processNext();\n  }\n}","map":{"version":3,"mappings":"AAeC;AAED,OAAM,MAAOA,cAAc;EAOvBC,YAAYC,SAAiB,EAAEC,aAA6B;IANpD,WAAM,GAAqB,EAAE;IAI7B,WAAM,GAAY,IAAI;IAG1B,MAAMC,IAAI,GAAG,IAAI;IAEjB,IAAIC,MAAM,EAAE;MACRD,IAAI,CAACE,WAAW,GAAG,IAAID,MAAM,CAACH,SAAS,EAAEC,aAAa,CAAC;MACvDC,IAAI,CAACE,WAAW,CAACC,SAAS,GAAGH,IAAI,CAACI,gBAAgB,CAACC,IAAI,CAACL,IAAI,CAAC;MAC7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AACE,MAAM,CAAC;;IAGzC,IAAI,CAACP,WAAW,GAAGQ,SAAS;IAC5B,IAAI,CAACV,YAAY,EAAE;EACvB","names":["ParallelHasher","constructor","workerUri","workerOptions","self","Worker","_hashWorker","onmessage","_recievedMessage","bind","onerror","err","_ready","console","error","hash","blob","promise","Promise","resolve","reject","_queue","push","_processNext","terminate","_processing","length","pop","postMessage","evt","data","success","result","undefined"],"sources":["/data/messenger.client/node_modules/ts-md5/src/parallel_hasher.ts"],"sourcesContent":["export interface WorkerOptions {\n    credentials?: 'omit' | 'same-origin' | 'include';\n    name?: string;\n    type?: 'classic' | 'module';\n}\n\ndeclare var Worker: {\n    prototype: Worker;\n    new (stringUrl: string, options?: WorkerOptions): Worker;\n};\n\ninterface HashingRequest {\n    blob: any;\n    resolve: (...d: any) => void;\n    reject: (...d: any) => void;\n};\n\nexport class ParallelHasher {\n    private _queue: HashingRequest[] = [];\n    private _hashWorker: any;\n    private _processing?: HashingRequest;\n\n    private _ready: boolean = true;\n\n    constructor(workerUri: string, workerOptions?: WorkerOptions) {\n        const self = this;\n\n        if (Worker) {\n            self._hashWorker = new Worker(workerUri, workerOptions);\n            self._hashWorker.onmessage = self._recievedMessage.bind(self);\n            self._hashWorker.onerror = (err: any) => {\n                self._ready = false;\n                console.error('Hash worker failure', err);\n            };\n        } else {\n            self._ready = false;\n            console.error('Web Workers are not supported in this browser');\n        }\n    }\n\n    /**\n     * Hash a blob of data in the worker\n     * @param blob Data to hash\n     * @returns Promise of the Hashed result\n     */\n    public hash(blob: any) {\n        const self = this;\n        let promise;\n\n        promise = new Promise((resolve, reject) => {\n            self._queue.push({\n                blob,\n                resolve,\n                reject,\n            });\n\n            self._processNext();\n        });\n\n        return promise;\n    }\n\n    /** Terminate any existing hash requests */\n    public terminate() {\n        this._ready = false;\n        this._hashWorker.terminate();\n    }\n\n    // Processes the next item in the queue\n    private _processNext() {\n        if (this._ready && !this._processing && this._queue.length > 0) {\n            this._processing = this._queue.pop();\n            this._hashWorker.postMessage(this._processing!.blob);\n        }\n    }\n\n    // Hash result is returned from the worker\n    private _recievedMessage(evt: any) {\n        const data = evt.data;\n\n        if (data.success) {\n            this._processing?.resolve(data.result);\n        } else {\n            this._processing?.reject(data.result);\n        }\n\n        this._processing = undefined;\n        this._processNext();\n    }\n}\n"]},"metadata":{},"sourceType":"module"}